import Vue from 'vue'
import App from './App'
import uView from "uview-ui";
import pop from 'static/js/popular.js'
import * as filters from 'filter/index.js'
import * as prototypeFuns from 'common/index.js'

import CellItem from 'components/cell/item.vue'
import CellField from 'components/cell/field.vue'
import PagesCourseRouterConfig from 'pagesCourse/routerConfig.js'
Vue.component('CellItem', CellItem)
Vue.component('CellField', CellField)

Vue.config.productionTip = false
Vue.prototype.$head = App.globalData.head2
Vue.use(uView);
Vue.prototype.$pop = pop
//获取当前时间
Vue.prototype.$getDate = () => {
	var date = new Date();
	var seperator1 = "-";
	var seperator2 = ":";
	var month = date.getMonth() + 1;
	var strDate = date.getDate();
	var hour = date.getHours()
	var min = date.getMinutes()
	month < 10 ? month = '0' + month : ''
	strDate < 10 ? strDate = '0' + strDate : ''
	hour < 10 ? hour = '0' + hour : ''
	min < 10 ? min = '0' + min : ''
	var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
		" " + hour + seperator2 + min;
	return currentdate;
}

Object.keys(filters).forEach(key => {
	Vue.filter(key, filters[key]);
});
Object.keys(prototypeFuns).forEach(item => {
	let obj = {}
	obj[`$${item}`] = prototypeFuns[item]
	Object.assign(Vue.prototype, obj)

})

Vue.prototype.$showloading = (msg = "") => {
	uni.showLoading({
		title: msg,
		mask: true
	})

}
Vue.prototype.$makephone = (number) => {

	uni.makePhoneCall({
		phoneNumber: number
	})

}
Vue.prototype.$navTo = function navTo(url) {
	if (!uni.getStorageSync('token')) {
		uni.showToast({
			title: '请先登录',
			icon: 'none'
		});
		setTimeout(() => {
			uni.navigateTo({
				url: '/pages/login/login'
			})
		}, 1500)
		return
	}
	uni.navigateTo({
		url,
		fail: () => {
			uni.switchTab({
				url
			})
		}
	})
}
Vue.prototype.$back = () => {
	uni.navigateBack({

	})
}
Vue.prototype.$go = function go(url) {
	uni.navigateTo({
		url,
		fail: () => {
			uni.switchTab({
				url
			})
		}

	})
}
Vue.prototype.$msg = function msg(msg) {
	uni.showToast({
		title: msg,
		icon: 'none'
	})

}
Vue.prototype.$compareTime = (startTime, endTime) => {
	var start = new Date(startTime.replace(/-/g, '/')).getTime() //开始时间
	var end = new Date(endTime.replace(/-/g, '/')).getTime() //结束时间
	if (start > end) {
		return true
	} else {
		return false
	}
}
Vue.prototype.$checkLogin = function() {
	if (!uni.getStorageSync('token')) {
		uni.showToast({
			title: '请先登录',
			icon: 'none'
		});
		setTimeout(() => {
			uni.navigateTo({
				url: '/pages/login/login'
			})
		}, 1500)
		return true
	}
}
//上传图片
Vue.prototype.$chooseImg = (hospitalId) => {
	var header = {}
	var data = {}
	if ( uni.getStorageSync('token')) {
		header = {

			token:  uni.getStorageSync('token')
		}

	} else {
		
		data = {

			hospitalId:hospitalId|| uni.getStorageSync('hospitalId') ? uni.getStorageSync('hospitalId') : ''
		}
	}
	console.log(data,'data');
	return new Promise((resolve, reject) => {
		uni.chooseImage({
			count: 1,
			sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
			sourceType: ['camera', 'album'],
			success: function(res) {
				uni.showLoading({
					title: '上传中...'

				})
				// 判断文件类型
				var tempFilePaths = res.tempFilePaths;

				uni.uploadFile({
					url: 'https://jinyiweikeji.com/ywt/busLocalFile/upload',
					filePath: tempFilePaths[0],
					header,
					formData: data,
					name: 'file',
					success: uploadFileRes => {
						uni.hideLoading()
						let file = uploadFileRes.data;
						file = JSON.parse(file);
						if (file.code == -100) {
							uni.showToast({
								title: '登录失效，请重新登录',
								icon: 'none'
							});
							uni.removeStorageSync('isLogin')
							uni.removeStorageSync('token')
							setTimeout(() => {

								uni.navigateTo({
									url: '/pages/login/login'
								})
							}, 1500)
							return
						}
						resolve(file.body.body)
					}
				});
			},
			fail: (err) => {}
		});
	})

}
// 上传视频
Vue.prototype.$chooseVideo = (hospitalId) => {
	var header = {}
	var data = {}
	if (  uni.getStorageSync('token')) {
		header = {

			token:  uni.getStorageSync('token')
		}

	} else {

		data = {

			hospitalId:hospitalId ||  uni.getStorageSync('hospitalId') ? uni.getStorageSync('hospitalId') : ''
		}
	}
	return new Promise((resolve, reject) => {
		uni.chooseVideo({
			maxDuration: 15,
			sourceType: ['camera', 'album'],
			success: function(res) {
				uni.showLoading({
					title: '上传中...'

				})
				// 判断文件类型
				var tempFilePath = res.tempFilePath;

				if (res.size > 52428800) {
					uni.showModal({
						title: '文件大于50M',

					})
					return
				}
				uni.uploadFile({
					url: 'https://jinyiweikeji.com/ywt/busLocalFile/upload',
					filePath: tempFilePath,
					header,
					formData: data,
					name: 'file',
					success: uploadFileRes => {
						uni.hideLoading()
						let file = uploadFileRes.data;
						file = JSON.parse(file);
						if (file.code == -100) {
							uni.showToast({
								title: '登录失效，请重新登录',
								icon: 'none'
							});
							uni.removeStorageSync('isLogin')
							uni.removeStorageSync('token')
							setTimeout(() => {

								uni.navigateTo({
									url: '/pages/login/login'
								})
							}, 1500)
							return
						}
						resolve(file.body.body)

					}
				});
			}
		});
	})

}
// 上传文件
Vue.prototype.$uploadfile = (hospitalId) => {
	var header = {}
	var data = {}
	if ( uni.getStorageSync('token')) {
		header = {
			token:  uni.getStorageSync('token')
		}
	} else {

		data = {

			hospitalId:hospitalId|| uni.getStorageSync('hospitalId') ? uni.getStorageSync('hospitalId') : ''
		}
	}
	return new Promise((resolve, reject) => {
		wx.chooseMessageFile({
			count: 1,
			success: function(res) {

				const tempFilePath = res.tempFiles[0]
				uni.showLoading({
					title: '上传中...'
				})
				if (!
					/\.(doc|xls|ppt|pdf|docx|xlsx|pptx|gif|jpg|jpeg|png|GIF|JPG|PNG|mp4|rmvb|avi|ts)$/
					.test(tempFilePath.path)) {
					uni.showToast({
						title: '不支持此格式！',
						icon: 'none'

					})
					return
				}
				if (tempFilePath.size > 52428800) {
					uni.showModal({
						title: '文件大于50M',

					})
					return
				}
				uni.uploadFile({
					url: 'https://jinyiweikeji.com/ywt/busLocalFile/upload',
					filePath: tempFilePath.path,

					header,
					formData: data,
					name: 'file',
					success: (uploadFileRes) => {
						uni.hideLoading()
						let file = uploadFileRes.data;
						file = JSON.parse(file);
						if (file.code == -100) {
							uni.showToast({
								title: '登录失效，请重新登录',
								icon: 'none'
							});
							uni.removeStorageSync('isLogin')
							uni.removeStorageSync('token')
							setTimeout(() => {

								uni.navigateTo({
									url: '/pages/login/login'
								})
							}, 1500)
							return
						}
						resolve(file.body.body)
					},

				})
			}
		});
	})

}

Vue.prototype.$wxUploadFile = ({
	tempFilePath
}) => {
	var header = {}
	var data = {}
	if (uni.getStorageSync('token')) {
		header = {
			token: uni.getStorageSync('token')
		}
	} else {
		data = {
			hospitalId: uni.getStorageSync('hospitalId') ? uni.getStorageSync('hospitalId') : ''
		}
	}
	return new Promise((resolve, reject) => {
		wx.uploadFile({
			url: 'https://jinyiweikeji.com/ywt/busLocalFile/upload',
			filePath: tempFilePath,
			header,
			formData: data,
			name: 'file',
			success: (uploadFileRes) => {
				uni.hideLoading()
				let file = uploadFileRes.data;
				file = JSON.parse(file);
				if (file.code == -100) {
					uni.showToast({
						title: '登录失效，请重新登录',
						icon: 'none'
					});
					uni.removeStorageSync('isLogin')
					uni.removeStorageSync('token')
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/login/login'
						})
					}, 1500)
					return
				}
				resolve(file.body.body)
			},

		})
	})
}

Vue.prototype.$open = (src) => {

	var a = src.slice(0, 4)
	if (a === 'http') {
		src = src
	} else if (src) {
		src = uni.getStorageSync('imgUrl') + src
		console.log(src,'srcv');
	}
	if (/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(src)) {
		uni.previewImage({
			count: src,
			urls: [src]
		})
	} else if (/\.(mp4|rmvb|avi|ts)$/.test(src)) {
		uni.navigateTo({
			url: `${PagesCourseRouterConfig.Video}?src=${src}`
		})
	} else if (/\.(doc|xls|ppt|pdf|docx|xlsx|pptx)$/.test(src)) {
		wx.downloadFile({
			url: src,
			success: function(res) {
				uni.hideLoading()
				var Path = res.tempFilePath //返回的文件临时地址，用于后面打开本地预览所用
				wx.openDocument({
					filePath: Path,
					success: function(res) {},
					fail: (err) => {

					}
				})
			},
			fail: function(res) {
				uni.showModal({
					title: '下载文件失败！'
				})
			}
		})
	} else {
		uni.showModal({
			title: '不支持打开此文件格式'
		})
	}
	return

}
//时间过滤函数
Vue.filter('alltime', function(value) {
	var unixTimestamp = new Date(value * 1000);
	Date.prototype.toLocaleString = function() {
		var year = this.getFullYear()

		var month = this.getMonth() + 1
		month > 9 ? '' : month = '0' + month
		var date = this.getDate()
		date > 9 ? '' : date = '0' + date
		var hour = this.getHours()
		hour > 9 ? '' : hour = '0' + hour
		var min = this.getMinutes()
		min > 9 ? '' : min = '0' + min
		var sec = this.getSeconds()
		sec > 9 ? '' : sec = '0' + sec
		return year + "-" + month + "-" + date + '  ' + hour + ':' +
			min + ':' + sec
	};
	let commonTime = unixTimestamp.toLocaleString();
	return commonTime
})
Vue.filter('time', function(value) {
	var unixTimestamp = new Date(value * 1000);
	Date.prototype.toLocaleString = function() {
		var year = this.getFullYear()

		var month = this.getMonth() + 1
		month > 9 ? '' : month = '0' + month
		var date = this.getDate()
		date > 9 ? '' : date = '0' + date
		return year + "-" + month + "-" + date
	};
	let commonTime = unixTimestamp.toLocaleString();
	return commonTime
})
//判断图片是否加了域名
Vue.filter('image', function(value = '') {
	var a = value.slice(0, 4)
	if (a === 'http') {
		return value
	} else if (value) {
		return uni.getStorageSync('imgUrl') + value
	} else {
		return '/static/images/photo.png'
	}
})
// 工单字段过滤*************************************************************************
Vue.prototype.$reason = (state, value) => { //流程原因
	if (state == 'suspend') {
		var list = uni.getStorageSync('dic').suspendReason
		var name = ''
		list.forEach(item => {
			if (item.value == value) {
				name = item.name
			}
		})
		return name
	} else if (state == 'back' || state == 'end_termination') {
		var list = uni.getStorageSync('dic').stopReason
		var name = ''
		list.forEach(item => {
			if (item.value == value) {
				name = item.name
			}
		})
		return name
	} else if (state == 'no_examine') {

		var list = uni.getStorageSync('dic').noExamine
		var name = ''
		list.forEach(item => {
			if (item.value == value) {
				name = item.name
			}
		})
		return name

	} else {
		var list = uni.getStorageSync('dic').transReason
		var name = ''
		list.forEach(item => {
			if (item.value == value) {
				name = item.name
			}
		})
		return name
	}
}
//处理故障范围
Vue.filter('rangeType', function(value) {
	var list = uni.getStorageSync('dic').faultScope
	var name = '个人'
	list.forEach(item => {
		if (item.value == value) {
			name = item.name
		}
	})
	return name
})
//处理单位
Vue.filter('rangeType', function(value) {
	var list = uni.getStorageSync('dic').faultScope
	var name = '个人'
	list.forEach(item => {
		if (item.value == value) {
			name = item.name
		}
	})
	return name
})
//处理故障范围颜色
Vue.prototype.$rangeTypeColor = (value) => {
	var color = ''
	switch (value) {
		case "1":
			color = '#656565';
			break;
		case "2":
			color = '#F5BB00';
			break;
		case "3":
			color = '#F5BB00';
			break;
		case "4":
			color = '#F56C6C';
			break;
		case 1:
			color = '#656565';
			break;
		case 2:
			color = '#F5BB00';
			break;
		case 3:
			color = '#F5BB00';
			break;
		case 4:
			color = '#F56C6C';
			break;
		default:
			color = ' #656565';

	}
	return color
}
//处理紧急程度
Vue.filter('degree', function(value) {
	var list = uni.getStorageSync('dic').gradeUrgency
	var name = '常规处理'
	list.forEach(item => {
		if (item.value == value) {
			name = item.name
		}
	})
	return name
})
//处理紧急程度颜色
Vue.prototype.$degreeColor = (value) => {
	var color = ''
	switch (value) {
		case "1":
			color = '#F56C6C';
			break;
		case "2":
			color = '#F5BB00';
			break;
		case "3":
			color = '#656565';
			break;
		case 1:
			color = '#F56C6C';
			break;
		case 2:
			color = '#F5BB00';
			break;
		case 3:
			color = '#656565';
			break;
		default:
			color = ' #656565';

	}
	return color
}
//处理流程状态
const progressType = [{
		label: '电话已解决',
		value: 'end_phone',
		person: '解决人'
	},
	{
		label: '创建工单',
		value: 'start',
		person: '创建人'
	},
	{
		label: '待接单',
		value: 'create',
		person: '派单人'
	}, {
		label: '暂停',
		value: 'suspend',
		text: '暂停原因',
		person: '暂停人'
	}, {
		label: '接单',
		// label: '处理中',
		value: 'receiving',
		person: '接单人'
	},
	{
		label: '退回',
		value: 'back',
		text: '退回原因',
		person: '退回人'
	},
	{
		label: '转交',
		value: 'forward',
		text: '转交原因',
		person: '转交人'
	},
	{
		label: '处理中',
		value: 'not_complete',
		text: '处理过程',
		person: '处理人'
	}, {
		label: '终止',
		value: 'end_termination',
		text: '终止原因',
		person: '终止人'
	}, {
		// label: '开启工单',
		label: '处理中',
		value: 'open_suspend',
		person: '处理人'
	}, {
		label: '重启工单',
		value: 'open_termination',
		person: '重启人'
	}, {
		label: '完成',
		value: 'complete',
		person: '完成人'

	}, {
		label: '未通过审核',
		value: 'no_examine',
		text: '驳回原因',
		person: '审核人'
	},
	{
		label: '审核通过',
		value: 'end_examine',
		person: '审核人'
	}
];
Vue.filter('processState', function(value) {

	var name = '处理中'
	progressType.forEach(item => {

		if (item.value == value) {
			name = item.label
		}
	})
	return name
})
Vue.filter('processStateText', function(value) {

	var name = '原因'
	progressType.forEach(item => {

		if (item.value == value) {
			name = item.text
		}
	})
	return name
})
Vue.filter('processPerson', function(value) {

	var name = '处理人'
	progressType.forEach(item => {

		if (item.value == value) {
			name = item.person
		}
	})
	return name
})
//处理流程颜色
Vue.prototype.$statusColor = (value) => {
	var color = ''
	switch (value) {
		case "create":
			color = '#F56C6C';
			break;
		case "end_examine":
			color = '#F5BB00';
			break;
		case "complete":
			color = '#1A1A1A';
			break;
		case "end_termination、close":
			color = '#999999';
			break;

		default:
			color = ' #409EFF';

	}
	return color
}


//处理科室
Vue.filter('subject', function(value = '') {
	var name = "无"
	name = deptId(value)
	return name
})
//获取用户自身
Vue.prototype.$getUser = () => {
	var name = uni.getStorageSync('username')
	var list = uni.getStorageSync('user')
	for (var key in list) {
		if (list[key] == name) {
			return {
				name,
				value: key,
				id: key
			}
		}
	}


}
//获取用户自身
Vue.prototype.$getOtherUser = (str) => {

	str = String(str)
	var arr = str.split(',')
	var name = []
	var value = []
	var list = uni.getStorageSync('user')
	arr.forEach(item => {
		for (var key in list) {
			if (key == item) {
				name.push(list[key])
				value.push(key)
			}
		}
	})

	return {
		name: name.join('/'),
		value: value.join(','),
		id: value.join(','),
	}

}
//获取用户默认科室
Vue.prototype.$getdept = (value = '') => {
	var name = "无"
	var value = value || uni.getStorageSync('dept').deptId
	name = deptId(value)
	return {
		name,
		value,
		id: value
	}

}

function deptId(id) {

	if (!id) {
		return;
	}
	let arr = [];
	arr = findParent(arr, id);
	return arr.join('/');
}

function findParent(arr, id) {
	const data = uni.getStorageSync('unit').find((item) => {
		return item.id == id
	});

	const pid = data?.parent;
	const name = data?.dept_name;
	if (pid === id) {
		return arr;
	}
	if (pid) {
		arr.unshift(name);
		return findParent(arr, pid);
	} else {
		arr.unshift(name);
		return arr;
	}
}

//处理公司名字
Vue.filter('company', function(value = '') {
	var name = ""
	var list = uni.getStorageSync('company')
	list.forEach(item => {
		if (item.id == value) {
			name = item.name
		}
	})

	return name
})
//处理故障分类
Vue.filter('faultType', function(value = '') {

	if (!value) {
		return '未选择'
	}

	value = value.split(',')
	var list = uni.getStorageSync('dic').faultClassification

	var name = []
	value.forEach((item => {
		list.forEach(item2 => {
			if (item2.id == item) {
				name.push(item2.name)
			}
		})
	}))
	return name.join('/')
})
//处理
Vue.filter('source', function(value) {

	var list = uni.getStorageSync('dic').faultSource
	var name = '未知'
	list.forEach(item => {
		if (item.value == value) {
			name = item.name
		}
	})
	return name
})
//处理响应类型
Vue.filter('responseType', function(value) {

	var list = uni.getStorageSync('dic').responseType
	var name = '即刻维修'
	list.forEach(item => {
		if (item.value == value) {
			name = item.name
		}
	})
	return name
})
// 项目字段过滤*************************************************************************

// 处理紧急程度
Vue.prototype.$getLevel = (value) => {
	var list = uni.getStorageSync('dic').itemLevel
	var obj = {}
	list.forEach(item => {
		if (item.value == value) {
			obj = item
		}
	})
	return obj
}
// 处理任务分类
Vue.prototype.$getTasktype = (value) => {
	var list = uni.getStorageSync('dic').taskType
	var obj = null
	list.forEach(item => {
		if (item.value == value) {
			obj = item
		}
	})
	return obj
}






Vue.prototype.$getSys = (value) => {
	var systems = value.split(',')
	var list = uni.getStorageSync('dic').aboutSystem
	var array = []
	systems.forEach(item => {
		list.forEach(item2 => {
			if (item2.value == item) {
				array.push(item2.name)
			}
		})
	})

	var name = array.join('/')
	return {
		name,
		value
	}
}
// 项目紧急程度
Vue.filter('itemPriority', function(value = '') {

	var list = uni.getStorageSync('dic').itemPriority
	var name = ''
	list.forEach(item => {
		if (item.value == value) {
			name = item.name
		}
	})
	return name
})
// 项目级别
Vue.filter('itemProjectLevel', function(value = '') {

	var list = uni.getStorageSync('dic').itemProjectLevel
	var name = ''
	list.forEach(item => {
		if (item.value == value) {
			name = item.name
		}
	})
	return name
})

//处理金额
Vue.filter('price', function(num = 0) {

	if (num) {
		//将num中的$,去掉，将num变成一个纯粹的数据格式字符串
		num = num.toString().replace(/\$|\,/g, '');
		//如果num不是数字，则将num置0，并返回
		if ('' == num || isNaN(num)) {
			return 'Not a Number ! ';
		}
		//如果num是负数，则获取她的符号
		var sign = num.indexOf("-") > 0 ? '-' : '';
		//如果存在小数点，则获取数字的小数部分
		var cents = num.indexOf(".") > 0 ? num.substr(num.indexOf(".")) : '.00';
		cents = cents.length > 1 ? cents : ''; //注意：这里如果是使用change方法不断的调用，小数是输入不了的
		//获取数字的整数数部分
		num = num.indexOf(".") > 0 ? num.substring(0, (num.indexOf("."))) : num;
		//如果没有小数点，整数部分不能以0开头
		if ('' == cents) {
			if (num.length > 1 && '0' == num.substr(0, 1)) {
				return 'Not a Number ! ';
			}
		}
		//如果有小数点，且整数的部分的长度大于1，则整数部分不能以0开头
		else {
			if (num.length > 1 && '0' == num.substr(0, 1)) {
				return 'Not a Number ! ';
			}
		}
		//针对整数部分进行格式化处理，这是此方法的核心，也是稍难理解的一个地方，逆向的来思考或者采用简单的事例来实现就容易多了
		/*
		  也可以这样想象，现在有一串数字字符串在你面前，如果让你给他家千分位的逗号的话，你是怎么来思考和操作的?
		  字符串长度为0/1/2/3时都不用添加
		  字符串长度大于3的时候，从右往左数，有三位字符就加一个逗号，然后继续往前数，直到不到往前数少于三位字符为止
		 */
		for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) {
			num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
		}
		//将数据（符号、整数部分、小数部分）整体组合返回
		return (sign + num + cents);
	} else {
		return '0.00'
	}

})
//处理任务状态
//处理流程状态
const taskType = [{
		name: '创建任务',
		value: '1'
	},
	{
		name: '提交任务',
		value: '2'
	},
	{
		name: '转交任务',
		value: '3'
	},
	{
		name: '暂停任务',
		value: '4'
	},
	{
		name: '开启任务',
		value: '5'
	},
	{
		name: '终止任务',
		value: '6'
	},
	{
		name: '审核完成',
		value: '7'
	},
	{
		name: '审核驳回',
		value: '8'
	},
	{
		name: '处理任务',
		value: '9'
	},
	{
		name: '完成任务',
		value: '10'
	}
];
Vue.filter('taskType', function(value) {

	var name = '处理任务'
	taskType.forEach(item => {

		if (item.value == value) {
			name = item.name
		}
	})
	return name
})
// 处理子任务流程状态
const state = [{
		name: '待提交',
		color: '#F56C6C'
	},
	{
		name: '处理中',
		color: '#07C160'
	},
	{
		name: '待审核',
		color: '#409EFF'
	},
	{
		name: '驳回',
		color: '#F56C6C'
	},
	{
		name: '暂停',
		color: '#EBB917'
	},
	{
		name: '终止',
		color: '#F56C6C'
	},
	{
		name: '已完成',
		color: '#98A5B3'
	}
]
Vue.prototype.$filterState = (num) => {

	switch (num) {
		case 0:
			return state[0];
			break;
		case 1:
			return state[1];
			break;
		case 2:
			return state[2];
			break;
		case 3:
			return state[3];
			break;
		case 4:
			return state[4];
			break;
		case 5:
			return state[5];
			break;
		case 6:
			return state[6];
			break;
		default:
			return state[0];
			break;
	}
}
//////////////////////////////////////////////////////////////////会议模块、、、、、、、、、、、、、、、、、、、、、
// 处理会议流程状态
const meetingstate = [{
		name: '未召开(未审核)',
		color: '#EBB917'
	},

	{
		name: '进行中',
		color: '#409EFF'
	},

	{
		name: '完成',
		color: '#07C160'
	},
	{
		name: '驳回',
		color: '#F56C6C'
	},
	{
		name: '未审核(作废)',
		color: '#F56C6C'
	},
	{
		name: '驳回已过期',
		color: '#F56C6C'
	},

	{
		name: '通过',
		color: '#409EFF'
	}

]
Vue.prototype.$meetingState = (num) => {

	switch (num) {
		case 0:
			return meetingstate[0];
			break;
		case 1:
			return meetingstate[1];
			break;
		case 2:
			return meetingstate[2];
			break;
		case 3:
			return meetingstate[3];
			break;
		case 4:
			return meetingstate[4];
			break;
		case 5:
			return meetingstate[5];
			break;
		case 6:
			return meetingstate[6];
			break;
		default:
			return meetingstate[0];
			break;
	}
}

//处理巡检单位
Vue.filter('valueUnit', function(value) {
	var list = uni.getStorageSync('dic').valueUnit
	var name = ''
	list.forEach(item => {
		if (item.value == value) {
			name = item.name
		}
	})
	return name
})
//处理会议类型
Vue.filter('meetingtype', function(value) {
	var list = uni.getStorageSync('dic').meeting_type
	var name = ''
	list.forEach(item => {
		if (item.value == value) {
			name = item.name
		}
	})
	return name
})
//处理数组名字拼接
Vue.prototype.$getNames = (arr = [], key = 'userName') => {
	var list = arr
	var name = []
	list.forEach(item => {
		name.push(item[key])
	})
	return name.join(',')
}
//处理会议类型
Vue.filter('devices', function(value) {
	var list = uni.getStorageSync('dic').metting_device
	var arr = value.split(',')
	var name = []
	list.forEach(item => {
		arr.forEach(item2 => {
			if (item2 == item.value) {
				name.push(item.name)
			}
		})

	})
	return name.join('/')
})


Vue.prototype.$getBackground = (item) => {


	if (!item) {
		return
	}
	let num = item.holidayType
	switch (num) {
		case 0:
			return {
				name: '',
					background: '#f5f7fa'
			};
			break;
		case 1:
			return {
				name: '休',
					background: '#fffcf2'
			};
			break;
		case 2:
			return {
				name: '节假日',
					background: '#fffcf2'
			};
			break;
		case 3:
			return {
				name: '节假日(休)',
					background: '#fffcf2'
			};
			break;

		default:
			return state[0];
			break;
	}
}


App.mpType = 'app'

export const app = new Vue({
	...App
})

app.$mount()
